package com.example.controller;


import com.example.pojo.User;
import com.example.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

//@RestController
@Controller
@RequestMapping("User")

public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("create")
    public String createAccount(User user,Model model){
        System.out.println(user.toString());
//        return userService.createAccount(user);
        model.addAttribute("message",userService.createAccount(user).get("message"));
        return "login";
    }

    @PostMapping("login")
    public String loginAccount(User user, Model model){
//        return userService.loginAccount(user);
        model.addAttribute("message",userService.loginAccount(user).get("message"));
        return "success";
    }
}

